package com.example.musicaiap.di

import android.content.Context
import androidx.media3.common.util.UnstableApi
import com.example.musicaiap.data.repository.FavoriteStateRepository
import com.example.musicaiap.data.repository.MusicRepository
import com.example.musicaiap.service.MediaBrowserHelper
import com.example.musicaiap.ui.player.PlayerController
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
@UnstableApi
object AppModule {
    
    @Provides
    @Singleton
    @UnstableApi
    fun provideMediaBrowserHelper(
        @ApplicationContext context: Context,
        musicRepository: MusicRepository
    ): MediaBrowserHelper {
        return MediaBrowserHelper(context, musicRepository)
    }
    
    @Provides
    @Singleton
    fun provideFavoriteStateRepository(
        @ApplicationContext context: Context
    ): FavoriteStateRepository {
        return FavoriteStateRepository(context)
    }
    
    @Provides
    @Singleton
    fun providePlayerController(
        mediaBrowserHelper: MediaBrowserHelper,
        musicRepository: MusicRepository,
        favoriteStateRepository: FavoriteStateRepository
    ): PlayerController {
        return PlayerController(mediaBrowserHelper, musicRepository, favoriteStateRepository)
    }
} 